package com.hsogoo.study.spring.resource;

import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.ResourceLoader;

/**
 * Created by za-huangsaigang on 2018/9/17.
 */
@Configuration
public class ResourceLoaderBeanTest {

    @Test
    public void testResourceLoaderBean(){
        ApplicationContext context = new AnnotationConfigApplicationContext(ResourceLoaderBean.class);
        ResourceLoaderBean resourceBean = context.getBean(ResourceLoaderBean.class);
        ResourceLoader loader = resourceBean.getResourceLoader();
        System.out.println(loader.getClass());
        //ResourceLoader instanceof ApplicationContext
        System.out.println(loader instanceof ApplicationContext);
    }

    @Bean
    public ResourceLoaderBean createResourceLoaderBean(){
        return new ResourceLoaderBean();
    }
}
